//
//  MineTableViewCell.m
//  ACE
//
//  Created by Mickey Yin on 2021/12/9.
//

#import "MineTableViewCell.h"

@implementation MineTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    // NSLog(@"cellForRowAtIndexPath");
    static NSString *identifier = @"MineTableViewCellid";
    // 1.缓存中取
    MineTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    // 2.创建
    if (cell == nil) {
        cell = [[MineTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = UIColor.whiteColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupView];
    }
    return self;
}

- (void)setupView {
    
    [self.contentView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(15);
        make.centerY.mas_equalTo(0);
    }];
    
    [self.contentView addSubview:self.iphoneLabel];
    [self.iphoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.nameLabel.mas_trailing).mas_offset(10);
        make.centerY.mas_equalTo(0);
    }];
}

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.font = PF_Medium(17);
        _nameLabel.textColor = RGBGlobal333;
    }
    return _nameLabel;
}

- (UILabel *)iphoneLabel {
    if (!_iphoneLabel) {
        _iphoneLabel = [[UILabel alloc] init];
        _iphoneLabel.font = PF_Medium(15);
        _iphoneLabel.textColor = RGBGlobal666;
    }
    return _iphoneLabel;
}

- (void)setTitleStr:(NSString *)titleStr {
    
    _nameLabel.text = titleStr;
}

- (void)setAddressbookModel:(AddressbookModel *)addressbookModel {
    
    _nameLabel.text = addressbookModel.iphoneName;
    _iphoneLabel.text = addressbookModel.iphoneNumber;
}

@end
